package encaps.utils.rendering;

import encaps.resources.Response;
import static encaps.utils.html.HTML.*;
import encaps.utils.html.HTMLElement;
import encaps.utils.html.Styles;
import org.jdom.Element;

public class ButtonFactory implements FieldFactory {

    @Override
    public HTMLElement renderField(Element e, boolean edit) {
        HTMLElement button = new HTMLElement(BUTTON);
        String label = e.getChildTextTrim(Response.LABEL);
        String key = e.getChildTextTrim(Response.KEY);
        String value = e.getChildTextTrim(Response.VALUE);

        button.addContent(label);
        button.addAttribute(NAME, key);
        button.addAttribute(VALUE, value);
        button.addAttribute(CLASS, Styles.COMMAND_BUTTON);
        return button;
    }
}
